$('.ico.add').on('click',function(){
    var latIndex=$('.searchinfo .searli').size()
    if(latIndex>=5) return;
    var  oIndex='txt'+(parseInt($('.searchinfo .searli').size())+parseInt(1))
    var  oType= oIndex +'_type';
    var  oTem = oIndex +'_tem';
    var  oBon = oIndex +'_bon';
    var  fuzzy= oIndex +'_fuzzy';
    var val2 = oIndex +'_val2';
    var val1 = oIndex +'_val1';
    const tempHtml='<div class="searli">'+
        '<div class="m-dropdown"> '+ 
          '<button class="btn" type="button"> '+
            '<div class="text">包含</div><img class="ico">'+ 
            '<input type="hidden" id="'+oType+'" name="'+oType+'">'+
          '</button>'+ 
          '<div class="list"> '+ 
            '<div class="item">并含</div>'+ 
            '<div class="item">包含</div>'+
            '<div class="item">或含</div>'+ 
          '</div>'+ 
        '</div>'+ 
        '<label class="cir">&nbsp;(</label>&nbsp;'+ 
        '<div class="m-dropdown">'+ 
          '<button class="btn" type="button">'+ 
            '<div class="text">标题</div><img class="ico">'+
            '<input type="hidden" id="'+oTem+'" name="'+oTem+'">'+ 
          '</button>'+ 
          '<div class="list"> '+ 
            '<div class="item">标题</div>'+ 
            '<div class="item">内容</div>'+ 
          '</div>'+ 
        '</div>'+ 
        '&nbsp;<input class="s-input" placeholder="请输入搜索内容" id="'+val1+'" name="'+val1+'">'+ 
        '&nbsp;<div class="m-dropdown"> '+ 
          '<button class="btn" type="button">'+ 
            '<div class="text">包含</div><img class="ico">'+
            '<input type="hidden" id="'+oBon+'" name="'+oBon+'">'+ 
          '</button>'+ 
          '<div class="list"> '+ 
            '<div class="item">并含</div>'+ 
            '<div class="item">包含</div>'+
            '<div class="item">或含</div>'+  
          '</div>'+ 
        '</div>'+ 
        '&nbsp;<input class="s-input" placeholder="请输入搜索内容" id="'+val2+'" name="'+val2+'">'+ 
        '&nbsp;<div class="m-dropdown">'+ 
          '<button class="btn" type="button">'+ 
            '<div class="text">精确</div><img class="ico">'+
            '<input type="hidden" id="'+fuzzy+'" name="'+fuzzy+'">'+ 
          '</button>'+ 
          '<div class="list">'+ 
            '<div class="item">精确</div>'+ 
            '<div class="item">模糊</div>'+ 
          '</div>'+ 
        '</div>'+ 
        '&nbsp;<label class="cir">)</label>'+ 
      '</div>'
    $('.searchinfo .searli:last').append(tempHtml)
    $('.m-dropdown').on('mousedown','.list>.item',function(e){
      const p=e.currentTarget.innerText
      const t=$(e.delegateTarget)
      t.find('button>.text').text(p)
      t.find('input:hidden').val(p)
    })
})
$('.ico.rel').on('click',function(){
  const latIndex=$('.searchinfo .searli').size()
  if(latIndex<=1){
    return false
  }
  $('.searli:eq('+(latIndex-1)+')').remove()
})
$('.m-dropdown').on('mousedown','.list>.item',function(e){
  const p=e.currentTarget.innerText
  const t=$(e.delegateTarget)
  t.find('button>.text').text(p)
  t.find('input:hidden').val(p)
})  
$('.btn.return').on('click',function(){
  window.history.go(-1)
})
$('.btn.slow').on('click',function(){
  $('.seresult').slideUp()
  $('.group input').each(function(){
    $(this).attr('disabled',false)
  })
  $('.searchbox>button').attr('disabled',false)
  $('.typesearch').val('0')
  $('.correlation').show()
})
$('.ck').on('click',function(){
  $('.seresult').slideDown()
  $('.group input').each(function(){
    $(this).attr('disabled',true)
  })
  $('.searchbox>button').attr('disabled',true)
  $('.typesearch').val('1')
  $('.correlation').hide()
})

$('.dh').on('click',function(){
  $('.result-res>.item>label>input:checkbox').each(function(){
    if($(this).is(':checked')){
      $('.bomp').css('display','block')
    setTimeout(function(){
    $('.bomp').hide()
    },2000)
    }else{
      return 
    }
  })
  
})

var  oDiv=$('.patype>div');
var  oRest=$('.result-res');
$('.patype>div').on('click',function(){
  var _this=$(this)
  if(!_this.hasClass('active')){
    oDiv.removeClass('active')
    _this.addClass('active')
  }
  if(_this.hasClass('list')){
    oRest.addClass('list')
  }else{
    oRest.removeClass('list')
  }

})
$('.correlation').on('click',function(){
  $(this).toggleClass('active')
})
function ff(id){
  if($(id).is(':checked')){
    $(id).parent().find('span').text('已收藏')
  }else{
    $(id).parent().find('span').text('收藏')
  }
}
// $('.result-res .btns .star input[type="checkbox"]').on('change',function(){

// })
function getNowFormatDate(off) {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    var hour=date.getHours();
    var minutes=date.getMinutes();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    if(minutes<10){
        minutes= "0"+minutes
    }
    if(hour<10){
      hour="0"+hour
    }
    if(off){
    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
            + " " + hour + seperator2 + minutes;
    }else{
      var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
            + " " + '00' +seperator2+ '00';    
    }

    return currentdate;
}
function dateSet(){
  var oDate=getNowFormatDate(true)
  var oDate1=getNowFormatDate(false)
  $('.datetime[name="stime"]').attr('value',oDate1)
  $('.datetime[name="etime"]').attr('value',oDate)
}
$('.seltime,.ck').on('click',function(){
  dateSet()
})
dateSet()
$('.add-btn').on('click',function(){
  $('.m-fwin-addlist').show()
})


/*2017 09 14*/
$('.x-dn').on('click','a',function(){
  var arr=[]
  $('.x-city>.x-xont').each(function(){
    arr.push($(this).attr('data-s').toString().substring(0,1))
  })
  $(this).addClass('active').siblings().removeClass('active')
  var sele=$(this).html();
  var oIndex=arr.indexOf(sele)
  if(oIndex!=-1){
    var oH=0;
    for(var i=0;i<oIndex;i++){
      oH+=$('.x-xont').height()+10
    }
    $('.x-city').animate({ scrollTop: oH },500)
  }else{
    return false
  }

})
$('.x-city').on('click','a',function(){
  $('.x-city a').removeClass('active')
  $(this).addClass('active')
})
/*2017 09 14*/
$('.result-res').on('click',' .btns>.star>input ',function(){
        var This=$(this)
        $(this).collect(function(result){
            if(result){
              This.addClass('active')
            }else{
              This.removeClass('active')
            }
        })
    
})

$('.x-city>.x-xont').each(function(val){
  var THis=$(this);
  THis.a=true
  THis.on('click',function(){
    if(THis.a){
      THis.find('.x-list').show()
    }else{
      THis.find('.x-list').hide()  
    }
    THis.a=! THis.a
  }
)
})


